package m.html.form;

import m.html.element.Element;
import m.html.element.other.IElement;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FormElement extends AbstractFormItem<FormElement> {
    @Override
    protected IElement getItemElement() {return null;}
    private FormElement(){this.eles=new ArrayList<>();
    }
    private final List<IElement> eles;

    /**
     * 添加元素
     */
    public static FormElement add(IElement... ele){
        FormElement fe=new FormElement();
        fe.eles.addAll(Arrays.asList(ele));
        return fe;
    }
    @Override
    protected IElement getElement() {
        IElement[] ls=eles.toArray(new IElement[0]);
        if(FormMode.ROW==this.mode) {
            return Element.tag("div").A("style", "width: 100%;padding-bottom: 15px;").E(ls);
        }else{
            return Element.tag("a-descriptions-item").A(":labelStyle","{display:'none'}").A("span", String.valueOf(this.col)).E(ls);
        }
    }
}
